//
//  LSFiltrateCompetitionCell.m
//  LookScore
//
//  Created by wr on 2018/1/26.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSFiltrateCompetitionCell.h"
#import "LSExponentModel.h"
#import "LSDataLeagueModel.h"
@implementation LSFiltrateCompetitionCell

+(LSFiltrateCompetitionCell *)FiltrateCompetitionCellBycollectionView:(UICollectionView *)CollectionView indexPath:(NSIndexPath *)indexPath{
    LSFiltrateCompetitionCell *cell=[CollectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(self) forIndexPath:indexPath];
    return cell;
}


-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self addContentView];
        
    }
    return self;
}
-(void)addContentView{
   
    UIButton *competitionBu=[UIButton new];
    competitionBu.frame=CGRectMake(LSSpaceLeftWidth1, 12,self.contentView.width-LSSpaceLeftWidth1-12, self.contentView.height-12);
    [competitionBu setTitleColor:LSTitleGrayColor3 forState:UIControlStateNormal];
    competitionBu.titleLabel.font=LSFontSize13;
    competitionBu.layer.cornerRadius=3;
    competitionBu.layer.masksToBounds=YES;
    competitionBu.layer.borderColor=LSTitleGrayColor3.CGColor;
    competitionBu.layer.borderWidth=.5f;
    competitionBu.backgroundColor=[UIColor whiteColor];
    competitionBu.userInteractionEnabled=NO;
    [competitionBu setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    [competitionBu setTitleColor:LSTitleGrayColor3 forState:UIControlStateNormal];
    [self.contentView addSubview:competitionBu];
    self.competitionBu=competitionBu;
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:competitionBu.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:competitionBu.bounds.size];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    //设置大小
    maskLayer.frame = competitionBu.bounds;
    //设置图形样子
    maskLayer.path = maskPath.CGPath;
  
    
 }


- (void)setComModel:(LSDataLeagueModel *)comModel{
    
    _comModel =comModel;
    if (comModel.isBtnSelected) {
        self.competitionBu.selected = YES;
        self.competitionBu.backgroundColor=LSSubColorFF9E44;
        self.competitionBu.layer.borderColor=LSSubColorFF9E44.CGColor;
    }else{
        self.competitionBu.selected = NO;
        self.competitionBu.backgroundColor=[UIColor whiteColor];
        self.competitionBu.layer.borderColor=LSTitleGrayColor3.CGColor;
    }
    [self.competitionBu setTitle:comModel.LeagueName_CN forState:UIControlStateNormal];
}

- (void)setModel:(LSExponentModel *)model{
    _model = model;
    if (model.isSelected) {
        self.competitionBu.selected = YES;
        self.competitionBu.backgroundColor=LSSubColorFF9E44;
        self.competitionBu.layer.borderColor=LSSubColorFF9E44.CGColor;
    }else{
        self.competitionBu.selected = NO;
        self.competitionBu.backgroundColor=[UIColor whiteColor];
        self.competitionBu.layer.borderColor=LSTitleGrayColor3.CGColor;
    }
    [self.competitionBu setTitle:model.LeagueName forState:UIControlStateNormal];
    
}

@end
